package cn.edu.buaa.cnsatm.traffic_big_data_server.highway.model;

import cn.edu.buaa.cnsatm.traffic_big_data_server.util.Point2D;

import java.awt.*;
import java.math.BigDecimal;

/**
 * @name = LX
 * @classname = RoadImageModel
 * @description =
 * @date = 2019/12/13
 */
public class RoadImageModel {
    //经度越往右越大，纬度越往下越小
    //x越往右越大，y越往上越大
    //i越往右越大，j越往下越大
    BigDecimal x, y, i, j, longitude, latitude;

    Color color;
    final static BigDecimal cellSize = new BigDecimal(256);

    public RoadImageModel(int x, int y, int i, int j) {
        this.x = new BigDecimal(x);
        this.y = new BigDecimal(y);
        this.i = new BigDecimal(i);
        this.j = new BigDecimal(j);
    }

    public RoadImageModel(int x, int y, int i, int j, double longitude, double latitude) {
        this.x = new BigDecimal(x);
        this.y = new BigDecimal(y);
        this.i = new BigDecimal(i);
        this.j = new BigDecimal(j);
        this.longitude = new BigDecimal(longitude);
        this.latitude = new BigDecimal(latitude);
    }

    public RoadImageModel(int x, int y, int i, int j, Color color) {
        this.x = new BigDecimal(x);
        this.y = new BigDecimal(y);
        this.i = new BigDecimal(i);
        this.j = new BigDecimal(j);
        this.color = color;
    }

    public BigDecimal xAxisPixelDiff(RoadImageModel aimPoint){
        /**
         * @name = LX
         * @classname = xAxisPixelDiff
         * @description = 计算目标点与当前点横向像素的差距（目标-当前，右减左）
         * @date = 2019/12/13
         */
        BigDecimal aimTotalX = aimPoint.x.multiply(cellSize).add(aimPoint.i);
        BigDecimal thisTotalX = this.x.multiply(cellSize).add(this.i);
        return aimTotalX.subtract(thisTotalX);
    }

    public BigDecimal yAxisPixelDiff(RoadImageModel aimPoint){
        /**
         * @name = LX
         * @classname = xAxisPixelDiff
         * @description = 计算目标点与当前点纵向向像素的差距（目标-当前）
         * @date = 2019/12/13
         */
        BigDecimal aimTotalY = aimPoint.y.multiply(cellSize).add(cellSize.subtract(aimPoint.j));
        BigDecimal thisTotalY = this.y.multiply(cellSize).add(cellSize.subtract(this.j));
        return aimTotalY.subtract(thisTotalY);
    }


    public BigDecimal getX() {
        return x;
    }

    public void setX(BigDecimal x) {
        this.x = x;
    }

    public BigDecimal getY() {
        return y;
    }

    public void setY(BigDecimal y) {
        this.y = y;
    }

    public BigDecimal getI() {
        return i;
    }

    public void setI(BigDecimal i) {
        this.i = i;
    }

    public BigDecimal getJ() {
        return j;
    }

    public void setJ(BigDecimal j) {
        this.j = j;
    }

    public BigDecimal getLongitude() {
        return longitude;
    }

    public void setLongitude(BigDecimal longitude) {
        this.longitude = longitude;
    }

    public BigDecimal getLatitude() {
        return latitude;
    }

    public void setLatitude(BigDecimal latitude) {
        this.latitude = latitude;
    }

    public Color getColor() {
        return color;
    }

    public void setColor(Color color) {
        this.color = color;
    }

    public static BigDecimal getCellSize() {
        return cellSize;
    }
}
